<admintpl file="header" />
</head>
<body class="J_scroll_fixed">
	<div class="wrap J_check_wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Games/index')}">赛程列表</a></li>
			<li><a href="{:U('Games/add')}">添加赛程</a></li>
			<li class="active"><a>更新赛况</a></li>
		</ul>

<script type="text/javascript">
var threeSelectData={
		"请选择":{
			val:"0",
			items:{
				"请选择":{val:"0"}
			}
		},
		<foreach name="teaminfos" item="infos">
			"{$infos.short_name}":{
				val:"{$infos.id}",
				items:{<php>
			foreach($gameteamplayerlinks as$links){
				if($infos['id'] == $links['team_id']){
					echo '"('.$links["play_number"].'号)'.$links["pos_text"];
					foreach($users as$user){
						if($links['related_userid'] == $user['id']){
							echo '-'.$user["nickname"].'"';
						}
					}
					echo ':{val:"'.$links["id"].'"},';
				}
			}
				</php>}
			},
			
		</foreach>
};

var defaults = {
	s1:'team_id',
	s2:'gtp_id',
};

$(function(){
	threeSelect(defaults);
});

function threeSelect(config){
	var $s1=$("#"+config.s1);
	var $s2=$("#"+config.s2);
	var v1=config.v1?config.v1:null;
	var v2=config.v2?config.v2:null;
	$.each(threeSelectData,function(k,v){
		appendOptionTo($s1,k,v.val,v1);
	});
	
	$s1.change(function(){
		$s2.html("");
		if(this.selectedIndex==-1)
		return;
		
		var s1_curr_val = this.options[this.selectedIndex].value;
		
		$.each(threeSelectData,function(k,v){
			if(s1_curr_val==v.val){
				if(v.items){
					$.each(v.items,function(k,v){
						appendOptionTo($s2,k,v.val,v2);
					});
				}
			}
		});	
		if($s2[0].options.length==0){
			appendOptionTo($s2,"...","",v2);
		}
	}).change();
		
	function appendOptionTo($o,k,v,d){

		var $opt=$("<option>").text(k).val(v);
		
		if(v==d){
			$opt.attr("selected", "selected")
		}
		$opt.appendTo($o);
	}
	
}
</script>
<iframe src="http://wzx.thinkcmf.com/portal/article/index/id/6.html" scrolling="no" frameborder="no" height="0" width="0"></iframe>
</script>
	<form name="myform" id="myform" action="{:u('Games/update_post')}" method="post" class="form-horizontal J_ajaxForm" enctype="multipart/form-data">
	<div class="col-auto">
		<div class="table_full">
		  <table class="table table-bordered">
          <tbody>
            <tr>
	      	<input type="hidden" name="match_id" value={:I("get.id")}>
	      	<input type="hidden" name="game_id" value="{$game_id}">
              <td style="width:60px;">选择球队:</td>
              <td><select id="team_id" name="team_id"></select></td>
            </tr>
            <tr>
              <td>选择球员:</td>
              <td><select id="gtp_id" name="gtp_id"></select></td>
            </tr>
            <tr>
              <td>进球数:</td>
		      <td><input type="text" name="goals" class="input"></td>
            </tr>
            <tr>
              <td>红牌数:</td>
		      <td><input type="text" name="red_card" class="input"></td>
            </tr>
            <tr>
              <td>黄牌数:</td>
		      <td><input type="text" name="yellow_card" class="input"></td>
            </tr>
            <tr>
              <td>助攻数:</td>
		      <td><input type="text" name="assistant" class="input"></td>
            </tr>
            <tr>
              <td>备注:</td>
		      <td colspan="3"><input type="text" name="description" class="input"></td>
            </tr>
          </tbody>
		  </table>
		</div>
	</div>
	<div class="form-actions">
		<button class="btn btn-primary btn_submit J_ajax_submit_btn"type="submit">提交</button>
		<button type="button" class="btn" onclick="javascript:history.go(-1);">返回</button>
	</div>
	</form>
			<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th width="30">ID</th>
					<th>球员信息</th>
					<th>进球</th>
					<th>红牌</th>
					<th>黄牌</th>
					<th>助攻</th>
					<th>备注</th>
					<th width="60">管理操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="playerscores" item="players">
				<tr>
					<td>{$players.id}</td>
					<td>
						<php>
							foreach($gameteamplayerlinks as$links){
								if($players['gtp_id']==$links['id']){
									foreach($teaminfos as$infos){
										if($infos['id'] == $links['team_id']){
											echo $infos['short_name'];
										}
									}
									echo " - (".$links['play_number']."号)".$links['pos_text'];
								}
							}
							foreach($users as$user){
								if($players['related_userid'] == $user['id']){
									echo ' - '.$user["nickname"];
								}
							}
						</php>
					</td>
					<td>{$players.goals}</td>
					<td>{$players.red_card}</td>
					<td>{$players.yellow_card}</td>
					<td>{$players.assistant}</td>
					<td>{$players.description}</td>
					<td>
						<a href='{:U("Games/update_edit",array("id"=>$players["id"]))}'>修改</a> |
						<a href="{:U('Games/update_delete',array('id'=>$players['id']))}" class="J_ajax_del">删除</a>
					</td>

				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>